import $ from 'jquery'

class ElementModel {
    constructor(data) {
        $.extend(this, {
            style: {}
        }, data)
    }

    get x() {
        return this.style.x
    }
    set x(x) {
        this.style.x = x
    }

    get y() {
        return this.style.y
    }
    set y(y) {
        this.style.y = y
    }

    get color() {
        return this.style.color
    }
    set color(color) {
        this.style.color = color
    }

    set type(type) {
        this.nodeType = 'MIDDLE'
        switch (type) {
            case 'input':
                this.nodeType = 'INPUT'
                this.taskType = null
                return
            case 'output':
                this.nodeType = 'OUTPUT'
                this.taskType = null
                return
            case 'join':
                this.taskType = 'JOIN'
                return
            case 'transformer':
                this.taskType = 'CLEAN'
                return
            case 'union':
                this.taskType = 'UNION'
                return
            case 'transposer':
                this.taskType = 'TRANSPOSE'
                return
            case 'row-transposer':
                this.taskType = 'COLTOROW'
                return
            case 'aggregator':
                this.taskType = 'DIMENSION'
                return
        }
    }

    get type() {
        switch (this.nodeType) {
            case 'INPUT':
                return 'input'
            case 'OUTPUT':
                return 'output'
            default: // middle node
                switch (this.taskType) {
                    case 'JOIN':
                        return 'join'
                    case "CLEAN":
                        return 'transformer'
                    case 'UNION':
                        return 'union'
                    case 'TRANSPOSE':
                        return 'transposer'
                    case 'COLTOROW':
                        return 'row-transposer'
                    case 'DIMENSION':
                        return 'aggregator'
                }
        }
    }
}

export default ElementModel